package com.westos.echufang.service.admin;

import com.westos.echufang.constants.RoleConstants;
import com.westos.echufang.dao.AdminDao;
import com.westos.echufang.dao.EmployeeDao;
import com.westos.echufang.pojo.entity.Admin;
import com.westos.echufang.pojo.entity.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    EmployeeDao employeeDao;
    @Autowired
    AdminDao adminDao;
    @Override
    public List<Employee> getEmps(Integer currentPageNo, Integer pageSize) {
        return null;
    }

    @Override
    public Employee getEmpById() {
        Employee emp=null;
        if (RoleConstants.employee!=null){
             emp = employeeDao.getEmpById(RoleConstants.employee.getId());
        }
        return emp;
    }

    @Override
    public Integer updateEmp(Employee employee) {
        return null;
    }

    @Override
    public Admin getPersonalInfor() {
        Admin admin=null;
        if (RoleConstants.admin!=null){
            admin = adminDao.queryPersonalInfor(RoleConstants.admin.getId());
        }
        return admin;
    }

    @Override
    public List<Employee> Emps() {
        return employeeDao.Emps();
    }

    @Override
    public int delEmp(int id) {
        int i = employeeDao.delEmps(id);
        return i;
    }

    @Override
    public List<Employee> EmpsByLimit(int pageSize, int pageIndex) {
        pageIndex=(pageIndex-1)*pageSize;
        List<Employee> emps = employeeDao.EmpsByLimit(pageSize, pageIndex);
        return emps;
    }

    @Override
    public int update(Employee employee) {
        int i = employeeDao.update(employee);
        return i;
    }

    @Override
    public Employee getEmpById(int id) {
        return employeeDao.getEmpById(id);
    }
}
